/**
 *
 */
package com.googlecode.bip.entity;

import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * TODO: doc
 *
 * @author Claude CHOISNET
 */
public class UserReferent
    implements IUserReferent, Serializable, Comparable<UserReferent>
{
    private static final long serialVersionUID = 1L;

    private int iduser; //key
    private int idreferent; //key

    /**
     *
     */
    public UserReferent()
    {
    }

    /**
     * Create a shadow copy of giving UserReferent
     *
     * @param o UserReferent to clone
     */
    public UserReferent( final UserReferent o )
    {
        this.iduser     = o.iduser;
        this.idreferent = o.idreferent;
    }

    @Override
    public int compareTo( final UserReferent o )
    {
        if( o == null ) {
            return Integer.MIN_VALUE;
            }
        if( this == o ) {
            return 0;
            }

        int cmp = this.iduser - o.iduser;
        if( cmp != 0 ) { return cmp; }

        cmp = this.idreferent - o.idreferent;
        return cmp;
    }

    /**
     *
     * @param rSet
     * @return
     * @throws SQLException
     */
    public IUserReferent set( final ResultSet rSet ) throws SQLException
    {
        // from uservalues
        iduser      = rSet.getInt( "iduser" );
        idreferent  = rSet.getInt( "idreferent" );

        return this;
    }

    @Override
    public int getIdUser()
    {
        return this.iduser;
    }

    @Override
    public void setIdUser( int iduser )
    {
        this.iduser = iduser;
    }

    @Override
    public int getIdReferent()
    {
        return this.idreferent;
    }

    @Override
    public void setIdReferent( int idreferent )
    {
        this.idreferent = idreferent;
    }

}
